package bite;

/**
 * Creared with IntelliJ IDEA.
 * Description://一年内的第几天
 * User:yxd
 * Date:2022-04-16
 * Time:21:13
 */

import java.util.Scanner;
public class Day14_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s  = input.nextLine();
        String[] nums = s.split(" ");
        int year = Integer.parseInt(nums[0]);
        int month = Integer.parseInt(nums[1]);
        int day = Integer.parseInt(nums[2]);
        int[] months = {0,31,28,31,30,31,30,31,31,30,31,30};
        if((year % 400 == 0) || (year % 4 == 0 && (year % 100) != 0)){
            months[3] = 29;
        }
        int sum = 0;
        for(int i = 0;i < month;i ++){
            sum += months[i];
        }
        sum += day;
        System.out.println(sum);
    }
}
